package com.source.db;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.commons.lang.StringUtils;

public class DbUser {

	public boolean createUser(String username){
		if(null == getUser(username)){
			//insert user here
		}
		return false;
	}
	
	public static String getUser(String username){
		String query = "SELECT name FROM user where name = '" + username + "'";
		try {
		    Connection conn = DbUtil.getConn();
		    Statement select = conn.createStatement();
		    ResultSet result = select.executeQuery(query);
		    while (result.next()) {
		        String s = result.getString(1);
		        if(!StringUtils.isEmpty(s)) return s;
		    }
		    select.close();
		    result.close();
		    conn.close();
		} catch(SQLException e) {
		        System.err.println("Mysql Statement Error: " + query);
		        e.printStackTrace();
		}
		return null;
	}
	
}
